package model

import (
	"server/common"
)

type Base struct {
	Model
	Name string `gorm:"column:name;not null;type:varchar(16);unique" json:"name"`
}

// 检查内容是否存在
func (b *Base) IsExist() bool {
	l := []Base{}
	if err := common.DB.Where("name = ? or id = ?", b.Name, b.ID).Find(&l).Error; err != nil {
		return false
	}
	if len(l) == 0 {
		return false
	}
	return true
}
